package defpackage; import defpackage.aazq; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /* renamed from: aago reason: default package */ public class aago { private static final String TAG = null; public aazt BVU; public aazx BVV; public aago BVW; private Map<String, aago> BVX = new LinkedHashMap(); @Deprecated public Map<String, abfz> BVY = new HashMap(); private int BVZ = 0; protected aaou pNP; public aago() { } public aago(aago aago, aazt aazt, aazx aazx) { this.BVU = aazt; this.BVV = aazx; this.BVW = aago; } public aago(aazp aazp) { int i = aazq.a.CBJ; aazy ahL = aazp.ahL("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"); if (ahL.size() == 0) { ahL = aazp.ahL("http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument"); if (ahL.size() != 0) { i = aazq.a.CBK; } } aazq.azr(i); ahL.size(); ew.eH(); this.BVV = ahL.azs(0); this.BVU = aazp.a(this.BVV); } public aago(aazt aazt, aazx aazx) { this.BVU = aazt; this.BVV = aazx; } public static aago a(aago aago, abgb abgb) { ew.assertNotNull("parent should not be null.", aago); ew.assertNotNull("descriptor should not be null.", abgb); return aago.a(abgb, abfq.heV()); } public static aago a(aago aago, abgb abgb, int i) { ew.assertNotNull("parent should not be null.", aago); ew.assertNotNull("descriptor should not be null.", abgb); return aago.a(abgb, abfq.heV(), i); } public static aago a(aago aago, abgb abgb, int i, String str) { return aago.a(abgb, abfq.heV(), i, str); } private aago a(aags aags, aagq aagq, int i, boolean z) { return a(aags, aagq, i, false, null); } private aago a(aags aags, aagq aagq, int i, boolean z, String str) { try { aazv aib = aazz.aib(aags.axC(i)); aazx aazx = null; aazt a = this.BVU.hdo().a(aib, aags.getContentType()); if (!z) { aazx = this.BVU.a(aib, abab.INTERNAL, aags.gVJ(), str); } aago a2 = aagq.a(aags); a2.BVV = aazx; a2.BVU = a; a2.BVW = this; if (!z) { f(aazx.id, a2); } return a2; } catch (Exception e) { throw new aagp(e); } } @Deprecated public static aags axB(int i) { ew.eH(); return abfz.CNl[i]; } private void f(String str, aago aago) { this.BVX.put(str, aago); aago.BVZ++; int i = aago.BVZ; } public final aago a(aags aags, aagq aagq) { return a(aags, aagq, -1, false); } public final aago a(aags aags, aagq aagq, int i) { return a(aags, aagq, i, false); } public final aago a(aags aags, aagq aagq, int i, String str) { return a(aags, aagq, i, false, str); } /* access modifiers changed from: protected */ public final void a(aagq aagq, Map<aazt, aago> map) throws aazk { aazt a; if (this.BVU != null) { aazp hdo = this.BVU.hdo(); Iterator<aazx> it = this.BVU.hde().iterator(); while (it.hasNext()) { aazx next = it.next(); if (next.CCe == abab.INTERNAL) { vpn hds = next.hds(); if (hds.fragment != null) { a = null; } else { a = hdo.a(aazz.f(hds)); if (a == null) { hm.e(TAG, "Skipped invalid entry " + next.hds()); } } if (!map.containsKey(a)) { aago a2 = aagq.a(this, next, a); if (a2 != null) { a2.BVW = this; f(next.id, a2); if (a != null) { map.put(a, a2); if (a.hdl()) { a2.a(aagq, map); } } } } else { f(next.id, map.get(a)); } } else if (next.CCe == abab.EXTERNAL) { bt(next.hds().toString(), next.eWp, next.id); } } } } public final void ahn(String str) { this.BVU.CBV.CCg.add(str); } public final aago aho(String str) { return this.BVX.get(str); } public boolean ahp(String str) { byte[] bArr = new byte[4096]; try { FileOutputStream fileOutputStream = new FileOutputStream(str); InputStream inputStream = this.BVU.getInputStream(); int i = 0; while (i != -1) { i = inputStream.read(bArr); if (i > 0) { fileOutputStream.write(bArr, 0, i); } } lul.a(fileOutputStream); return true; } catch (FileNotFoundException e) { hm.e(TAG, "FileNotFoundException: ", e); return false; } catch (IOException e2) { hm.e(TAG, "IOException: ", e2); if (!eia.e(e2)) { return false; } throw new aagp(e2); } } public final String b(aago aago) { for (Map.Entry<String, aago> entry : this.BVX.entrySet()) { if (entry.getValue() == aago) { return entry.getKey(); } } return null; } public void b(aaou aaou) { ew.assertNotNull("importer should not be null!", aaou); this.pNP = aaou; } public final void bt(String str, String str2, String str3) { this.BVU.bv(str, str2, str3); } public final List<aago> gVH() { return Collections.unmodifiableList(new ArrayList(this.BVX.values())); } public void gVI() throws IOException { } public final aazx iI(String str, String str2) { return this.BVU.bv(str, str2, null); } public String toString() { return this.BVU == null ? new String() : this.BVU.toString(); } }